﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Eudaemon.ProeAssist.Core.Properties;

namespace Eudaemon.ProeAssist.Core
{
    public abstract class ProeFileType
    {
        public string Name 
        { 
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }
        public string Abbreviation
        {
            get
            {
                return _abbreviation;
            }
            set
            {
                _abbreviation = value;
            }
        }

        public Bitmap IconResource
        {
            get
            {
                return _iconResource;
            }
            set
            {
                _iconResource = value;
            }
        }

        public static bool IsProeFileName(string fileFullName)
        {
            if (fileFullName == null)
                return false;
            string[] splits = fileFullName.Split(new Char[] { '.' });
            if (splits.Length != 3)
                return false;
            // 1. name; 2. file type(enumeration; 3. version number(positive integer).
            switch (splits[1].ToLower())
            {
                case "asm":
                    break;
                case "dgm":
                    break;
                case "drw":
                    break;
                case "frm":
                    break;
                case "lay":
                    break;
                case "mfg":
                    break;
                case "mrk":
                    break;
                case "prt":
                    break;
                case "rep":
                    break;
                case "sec":
                    break;
                default:
                    return false;
            }

            try
            {
                int version = Int32.Parse(splits[2]);
                if (version < 0)
                    return false;
            }
            catch (FormatException)
            {
            }
            return true;
        }

#region Private
        string _name;
        string _abbreviation;
        Bitmap _iconResource;
#endregion
    }

    public sealed class ProeAssemblyType : ProeFileType
    {
        public ProeAssemblyType()
        {
            Name = "Assembly";
            Abbreviation = "asm";
            IconResource = Resources.Assembly;
        }
    }

    public sealed class ProeDiagramType : ProeFileType
    {
        public ProeDiagramType()
        {
            Name = "Diagram";
            Abbreviation = "dgm";
            IconResource = Resources.Diagram;
        }
    }

    public sealed class ProeDrawingType : ProeFileType
    {
        public ProeDrawingType()
        {
            Name = "Drawing";
            Abbreviation = "drw";
            IconResource = Resources.Drawing;
        }
    }

    public sealed class ProeFormatType : ProeFileType
    {
        public ProeFormatType()
        {
            Name = "Format";
            Abbreviation = "frm";
            IconResource = Resources.Format;
        }
    }

    public sealed class ProeLayoutType : ProeFileType
    {
        public ProeLayoutType()
        {
            Name = "Layout";
            Abbreviation = "lay";
            IconResource = Resources.Layout;
        }
    }

    public sealed class ProeManufacturingType : ProeFileType
    {
        public ProeManufacturingType()
        {
            Name = "Manufacturing";
            Abbreviation = "mfg";
            IconResource = Resources.Manufacturing;
        }
    }

    public sealed class ProeMarkupType : ProeFileType
    {
        public ProeMarkupType()
        {
            Name = "Markup";
            Abbreviation = "mrk";
            IconResource = Resources.Markup;
        }
    }

    public sealed class ProePartType : ProeFileType
    {
        public ProePartType()
        {
            Name = "Part";
            Abbreviation = "prt";
            IconResource = Resources.Part;
        }
    }

    public sealed class ProeReportType : ProeFileType
    {
        public ProeReportType()
        {
            Name = "Report";
            Abbreviation = "rep";
            IconResource = Resources.Report;
        }
    }

    public sealed class ProeSketchType : ProeFileType
    {
        public ProeSketchType()
        {
            Name = "Sketch";
            Abbreviation = "sec";
            IconResource = Resources.Sketch;
        }
    }
}
